package com.group2.bankonline.mapper;

import com.group2.bankonline.pojo.Account;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author syf
 * @since 2024-07-11
 */

@Mapper
public interface AccountMapper extends BaseMapper<Account> {
    @Update("""
            update account set balance = #{balance} where id = #{aid};
            """)
    public int updateAccountBalance(@Param("balance") BigDecimal banlance,@Param("aid")int aid);

    @Select("""
            select * from account where id = #{id} and password = #{password};
            """)
    public Account selectByIdAndPassword(@Param("id")int id,@Param("password")String password);

    @Select("""
            select id from account where accountname=#{aname};
            """)
    public Integer selectByAccountName(@Param("aname")String name);

    @Select("""
            select personid from account where id = #{id};
            """)
    public int selectTelById(@Param("id")int id);

    public void bindAccount(Account account);

    boolean havepid(int pid);

    public int getpid(String accountname);

    public void accountchange(BigDecimal newbalance, String accountname);

    public String getpwd(String accountname);
    public BigDecimal getBalance(String accountname);

    public int getid(String accountname);

    public List<Account> getaccountname(int pid); //此处报错，但接口测试可正常运行
}
